﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JCFramework.Extensions
{
    public static class EnumExtensions
    {
        public static T ParseEnum<T>(this object o)
        {
            return (T)Enum.Parse(typeof(T), o.ToString(), true);
        }

        public static IEnumerable<T> GetValues<T>()
        {
            return Enum.GetValues(typeof(T)).Cast<T>();
        }

        public static T ParseTo<T>(this Enum self)
        {
            return (T)Enum.Parse(self.GetType(), self.ToString(), true);
        }

        public static bool Contains(this Enum parent, Enum ele)
        {
            return ((int)(object)parent | (int)(object)ele) == (int)(object)parent;
        }
    }
}
